package org.example.service.Impl;

import org.example.dao.ApprovalDao;
import org.example.entity.Approval;
import org.springframework.stereotype.Service;
import org.example.service.ApprovalService;

import javax.annotation.Resource;
import java.util.HashMap;

@Service
public class ApprovalServiceImpl implements ApprovalService {

    @Resource
    ApprovalDao approvalDao;

    @Override
    public Boolean addApproval(Approval approval) {
        return approvalDao.insert(approval)>0;
    }

    @Override
    public Boolean deleteApproval(Approval approval) {
        HashMap<String,Object> map=new HashMap<>();
        map.put("creationId",approval.getCreationId());
        map.put("userId",approval.getUserId());
        return approvalDao.deleteByMap(map)>0;
    }

    @Override
    public Integer getApprovalNumber(Long creationId) {
        HashMap<String,Object> map=new HashMap<>();
        map.put("creationId",creationId);
        return approvalDao.selectByMap(map).size();
    }
}
